home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13615 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: lrz-muenchen.de!news
  2. From: watzka@stat.uni-muenchen.de (Kurt Watzka)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Question on pointers
  5. Date: 9 Apr 1996 08:16:29 GMT
  6. Organization: Leibniz-Rechenzentrum, Muenchen (Germany)
  7. Distribution: world
  8. Message-ID: <4kd6ct$h5h@sparcserver.lrz-muenchen.de>
  9. References: <1996Apr8.233330.139449@forest>
  10. NNTP-Posting-Host: sun2.lrz-muenchen.de
  11.  
  12. ebromber@forest.drew.edu writes:
  13.  
  14. >In a program there is an array of structs. One of the headers for a 
  15. >function says void pop(stack *). My question is shouldn't there be a name 
  16. >or identifier after the asterisk?
  17.  
  18. A name for the formal parameter of a function is not needed in a
  19. function declaration. So, if this is a declaration, a "name" can
  20. be supplied (and it sometimes is used by compilers to create
  21. "better" diagnostics), but it is not needed.
  22.  
  23. >My friend says that it is the address of 
  24. >a stack in the array.
  25.  
  26. ?????
  27.  
  28. >If this is true, how could I access the thing 
  29. >pointed to?
  30.  
  31. You have to have names for formal parameters in a function _definition_.
  32. The parameter can be accessed through its name.
  33.  
  34. >Here are some lines which define a stack
  35.  
  36. >typedef struct item item;
  37. >struct item {
  38. >    struct item *next;
  39.  
  40. If you have "typedef"ed "item", why don't you use it as in
  41.  
  42.         item *next;
  43.  
  44. >    char c;
  45. >    }
  46. >typedef item *stack;
  47.  
  48. Kurt
  49. --
  50. | Kurt Watzka                             Phone : +49-89-2180-6254
  51. | watzka@stat.uni-muenchen.de
  52.